<template>
<div>
  <div>
    <h1>新增问题-快点来提交你的疑惑</h1>
  </div>
  <el-form :model="question" label-width="120px">
    <el-form-item label="问题">
      <el-input v-model="question.title" />
    </el-form-item>
    <el-form-item label="问题类型">
      <el-select v-model="question.type" placeholder="请选择问题的类型">
        <el-option label="技术点" value="技术点" />
        <el-option label="项目" value="项目" />
        <el-option label="生活" value="生活" />
        <el-option label="感情" value="感情" />
      </el-select>
    </el-form-item>
    <el-form-item label="问题描述">
      <el-input v-model="question.info" type="textarea" />
    </el-form-item>
    <el-form-item label="参考答案">
      <el-input v-model="question.answer" type="textarea" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="save">创建问题</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</div>
</template>

<script setup>
import {ref} from 'vue'
import axios from "axios";
import {useRouter} from 'vue-router'

const router = useRouter();
const question=ref({})

//新增
const save=()=>{
  //请求接口  Axios post json 语法格式
  axios.post("question/save",question.value).then(res=>{
    if(res.data.code==0){
      router.push("/list");
    }else{
      alert("亲，新增问题失败！")
    }
  })
}
</script>

<style scoped>

</style>
